package com.linkage.educloud.ah.view;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.FrameLayout;

import com.linkage.educloud.ah.R;
import com.zzhou.common.library.util.DisplayUtils;
import com.zzhou.common.library.util.LogUtils;

import butterknife.ButterKnife;

/**
 * <desc>
 * Created by The Moss on 2018/6/7.
 */

public abstract class BasicActivity extends AbstractActivity {
    View rootView;
    FrameLayout _mContentLayout;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LogUtils.d(TAG, TAG + " >>>> onCreate  <<<<");
        DisplayUtils.initScreen(this);
//        getDelegate().setContentView(R.layout.basic_activity);
        rootView = View.inflate(this, R.layout.basic_activity,null);
        _mContentLayout = rootView.findViewById(R.id._content);
        addContentView(attachLayoutRes());
    }

    public void addContentView(int layoutResID) {
        _mContentLayout.removeAllViews();
        if (layoutResID < 1) {
            LogUtils.e(TAG, "layout resouce id not exist");
            return;
        }
        LogUtils.d(TAG, ">>>>>>> setContentView");
        View view = View.inflate(this, layoutResID, null);
        if (view == null) {
            LogUtils.e(TAG, ">>>>>>> setContentView view is null");
            return;
        }
        _mContentLayout.addView(view);
        ButterKnife.setDebug(true);
        setContentView(rootView);
        ButterKnife.bind(this, rootView);
    }
}
